package com.bml.client.secret.demo.single;

import java.util.HashMap;

public class SimpleFactory {
    //懒汉式  饿汉式
    private static SimpleFactory factory;

    public static SimpleFactory getInstacne() {
        if (factory == null) {
            System.out.println(Thread.currentThread().getName());
            synchronized (SimpleFactory.class) {
                if (factory == null) {
                    System.out.println("创建对象");
                    factory = new SimpleFactory();
                }
            }
        }
        return factory;
    }

    private SimpleFactory() {

        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("simpleFActory",getInstacne());

    }

    public void test() {
        System.out.println(this);
        System.out.println(1111);
    }
}
